package com.branches.threads;

public class ThreadSync {
    public static void main(String[] args) {
//        Thread add = new AddThread();
//        Thread dec = new DecThread();
//        add.start();
//        dec.start();
//        try {
//            add.join();
//            dec.join();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        String ids = "[11, 111, 22]";
        System.out.println(ids.length() > 30 ? ids.substring(0, 10) : ids);
    }
}

class Counter {
    public static int count = 0;
}

class AddThread extends Thread {
    public void run() {
        for (int i = 0; i < 10000; i++) {
            synchronized (Counter.class) {
                Counter.count += 1;
            }
        }
    }
}

class DecThread extends Thread {
    public void run() {
        for (int i = 0; i < 10000; i++) {
            synchronized (Container.class) {
                Counter.count -= 1;
            }
        }
    }
}
